@foreach($collection as $category)
<ol class="dd-list">
    <li class="dd-item">
     <div style="position: relative;top: 3px;">


             <button type="button" data-color="teal" class="btn bg-red waves-effect btn-xs pull-right" class="btn btn-default waves-effect"  style="position: relative;top:0px;"><i class="material-icons" style="top: 0">remove</i></button>

         <button type="button" data-color="teal" class="btn btn-blue bg-teal waves-effect btn-xs pull-right" class="btn btn-default waves-effect" data-toggle="modal" data-target="#esmallModal{{$category->id}}" style="position: relative;top:0px;"><i class="material-icons" style="top: 0">edit</i></button>

            <button type="button" data-color="teal" class="btn btn-info bg-teal waves-effect btn-xs pull-right" class="btn btn-default waves-effect" data-toggle="modal" data-target="#smallModal{{$category->id}}" style="position: relative;top:0px;"><i class="material-icons" style="top: 0">add</i></button>

        
        <!-- Small Size -->
            <div class="modal fade" id="smallModal{{$category->id}}" tabindex="-1" role="dialog">
                <div class="modal-dialog modal-sm" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h4 class="modal-title" id="smallModalLabel{{$category->id}}">在"{{$category->name}}"添加子分类</h4>
                        </div>
                        <div class="modal-body">
                         <form action="{{ route('categories.store') }}" id="form_validation" method="POST">
                             {{csrf_field()}}
                             <input name="parent_id" type="hidden" value="{{$category->id}}">
                               <div class="form-group">
                                     <input class="form-control" name="name" placeholder="分类名称"required="" type="text">
                               </div>   
                               <div class="form-group">
                                   <input class="form-control" name="slug" placeholder="分类链接" required="" type="text" >
                               </div>

                                  
                                         <button class="btn btn-primary " type="submit">
                                             添加
                                         </button> 
                             </input>
                         </form>
                        </div>
                    </div>
                </div>
            </div>

        <!--edit -->
          <div class="modal fade" id="esmallModal{{$category->id}}" tabindex="-1" role="dialog">
                <div class="modal-dialog modal-sm" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h4 class="modal-title" id="esmallModalLabel">修改</h4>
                        </div>
                        <div class="modal-body">
                         <form action="{{ route('categories.update',$category->id) }}" id="form_validation" method="POST">
                             {{csrf_field()}}
                            {{method_field('PATCH')}}
                              @if($category->parent_id == 0)
                                <input type="hidden" name="parent_id" value="0">
                                @else
                                <input type="hidden" name="parent_id" value="{{$category->parent_id}}">
                              @endif
                               <div class="form-group">
                                     <input class="form-control" value="{{$category->name}}" style="border-bottom: 1px solid " name="name" placeholder="分类名称"required="" type="text">
                               </div>   

                               <div class="form-group">
                                   <input class="form-control" value="{{$category->slug}}" style="border-bottom: 1px solid " name="slug" placeholder="分类链接" required="" type="text" >
                               </div>
                              
                              <div class="form-group form-float color" @if(!$category->is_floor) style="display: none" @endif>
                                     <div class="input-group colorpicker">
                                        <div class="form-line">
                                            <input type="text" class="form-control zn" name="floor_color" value="#00AABB">
                                        </div>
                                        <span class="input-group-addon">
                                            <i></i>
                                        </span>
                                    </div>
                                </div>
 
                                <div class="form-group">
                                       <input class="filled-in floor" id="is_floor{{$category->id}}" name="is_floor" type="checkbox" value="1" @if($category->is_floor) checked @endif >
                                            <label for="is_floor{{$category->id}}">
                                                楼层推荐
                                            </label>
                                        </input>
                                </div> 
                                         
                                  
                             <button class="btn btn-primary " type="submit">
                                 修改
                             </button> 
                             </input>
                         </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
     <div class="dd-handle">

        {{$category->name}} 
       
     </div>
        
      
        @if (isset($categories[$category->id]))
                @include('admin.categories.list',['collection'=> $categories[$category->id]])
        @endif

    </li>
</ol>

{{-- <tr>
    <th scope="row">
        {{$loop->index+1}}
    </th>
    <td>
        @if($category->parent_id != 0)
                 --- {{$category->name}}
            @else
            {{$category->name}}
            @endif
    </td>
    <td>
        {{$category->products()->count()}}
    </td>
    <td>
        <form action="{{ route('categories.store') }}" id="form_validation" method="POST">
            {{csrf_field()}}
            <input name="parent_id" type="hidden" value="{{$category->id}}">
                        <input class="form-control" name="name" placeholder="分类名称" style="width:80px;height: 20px;"required="" type="text">
                        <input class="form-control" name="slug" placeholder="分类链接" required="" type="text" style="width: 80px;height: 20px;">
                 
                        <button class="btn btn-primary btn-xs" type="submit">
                            添加
                        </button> 
            </input>
        </form>
    </td>
    <td>
        <a class="btn bg-green btn-xs" data-target="#modal-{{$category->id}}" data-toggle="modal" href="#">
            <i class="material-icons">
                mode_edit
            </i>
            <span>
                编辑
            </span>
        </a>
        <div class="modal fade" id="modal-{{$category->id}}">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button aria-label="Close" class="close" data-dismiss="modal" type="button">
                            <span aria-hidden="true">
                                ×
                            </span>
                            <span class="sr-only">
                                Close
                            </span>
                        </button>
                        <h4 class="modal-title">
                            # {{$category->id}}
                        </h4>
                    </div>
                    <div class="modal-body">
                        <form action="{{ route('categories.update',$category->id) }}" id="form_validation" method="POST">
                            {{csrf_field()}}
                                {{method_field('PUT')}}
                            <div class="form-group form-float">
                                <div class="form-line">
                                    <input class="form-control" name="name" required="" type="text" value="{{$category->name}}">
                                        <label class="form-label">
                                            分类名称
                                        </label>
                                    </input>
                                </div>
                            </div>
                            <div class="form-group form-float">
                                <div class="form-line">
                                    <input class="form-control" name="slug" required="" type="text" value="{{$category->slug}}">
                                        <label class="form-label">
                                            分类链接
                                        </label>
                                    </input>
                                </div>
                            </div>
                            <div class="form-group form-float">
                                <div class="">
                                    <button class="btn btn-primary" type="submit">
                                        更新
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal-dialog -->
        </div>
        <!-- /.modal -->
        <form action="{{ route('categories.destroy',$category->id) }}" method="post" style="display: inline">
            {{csrf_field()}}
                {{method_field('DELETE')}}
            <button class="btn bg-red btn-xs " type="submit">
                <i class="material-icons">
                    delete
                </i>
                <span>
                    删除
                </span>
            </button>
        </form>
    </td>
</tr>
<tr>
    @if (isset($categories[$category->id]))
                @include('admin.categories.list',['collection'=> $categories[$category->id]])
        @endif
</tr> --}}
@endforeach
